package com.hanggold.jfinal.springframework.processors;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-10-09 09:23
 * @since 1.0.0
 **/
@Component
public class MyPriorityOrderDefaultBeanPostProcessors implements BeanPostProcessor, PriorityOrdered, InitializingBean {

    @Value("${username.username}")
    private String usernameusernae;

    @Value("${username}")
    private String username;

    @Resource(name = "systemProperties")
    private Map<String, Object> systemProperties;

    @Resource(name = "systemEnvironment")
    private Map<String, Object> systemEnvironment;

    public MyPriorityOrderDefaultBeanPostProcessors() {
        System.out.println("构造函数。。。");
    }

    @Override
    public int getOrder() {
        return 0;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println(123456);
    }

}
